---
title: typescript-validation-schema
description: A plugin for GraphQL Codegen to generate form validation schema (such as yup, zod) based on your GraphQL schema for use in a client application.
---

import { PluginHeader } from '@/components/plugin'
import { pluginGetStaticProps } from '@/lib/plugin-get-static-props'
export const getStaticProps = pluginGetStaticProps(__filename)

<PluginHeader />

_Built and maintained by [Code-Hex](https://github.com/Code-Hex)_

A plugin for GraphQL Codegen to generate form validation schema (such as [yup](https://github.com/jquense/yup), [zod](https://github.com/colinhacks/zod)) based on your GraphQL schema for use in a client application.

## Examples

Set up your project per the GraphQL Codegen Docs, and specify this plugin in your `codegen.yml`:

```ts filename="codegen.ts"
import type { CodegenConfig } from '@graphql-codegen/cli'

const config: CodegenConfig = {
  generates: {
    'path/to/graphql.ts': {
      plugins: ['typescript', 'typescript-validation-schema'],
      config: {
        strictScalars: true,
        schema: 'yup'
      }
    }
  }
}
export default config
```

## Usage & Documentation

For the complete documentation, please refer to [Code-Hex/graphql-codegen-typescript-validation-schema](https://github.com/Code-Hex/graphql-codegen-typescript-validation-schema) repository.
